package summerbug.hanzi;

import android.app.Application;
import android.database.sqlite.SQLiteDatabase;
import android.widget.Button;

import summerbug.hanzi.model.dao.DaoMaster;
import summerbug.hanzi.model.dao.DaoSession;

/**
 * Created by 76336 on 2018/5/13.
 */

public class MyApplication extends Application {

    private DaoMaster.DevOpenHelper mHelper;
    private SQLiteDatabase db;
    private DaoMaster mDaoMaster;
    private DaoSession mDaoSession;
    private static MyApplication instance;
    public static final String DB_NAME = "xhzd_data";


    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;
        setDataBase();


    }

    private void setDataBase() {
        mHelper = new DaoMaster.DevOpenHelper(this,DB_NAME,null);
        db = mHelper.getWritableDatabase();
        mDaoMaster = new DaoMaster(db);
        mDaoSession = mDaoMaster.newSession();
    }

    public static MyApplication getInstance() {
        return instance;
    }

    public DaoSession getDaoSession() {
        return mDaoSession;
    }
}
